package com.nf.handler;

import com.nf.MiniResultHandler;
import com.nf.MiniRowProcessor;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

public class MiniMapHandler implements MiniResultHandler<Map<String, Object>> {
    private MiniRowProcessor convert=null;

    public MiniMapHandler() {
        this(Constants.DEFAULT_ROW_PROCESSOR);
    }

    public MiniMapHandler(MiniRowProcessor convert) {
        this.convert = convert;
    }

    @Override
    public Map<String, Object> handle(ResultSet rs) throws SQLException {
        return rs.next()?this.convert.toMap(rs):null;
    }
}
